<?php

namespace App\Services\Statistics;

use Carbon\Carbon;
use App\Models\Statistic;
use App\Models\User;


class SoftCountCharts
{
	public function usersIncrease()
	{
		return [
			'labels' => [
				Carbon::today()->addDays(-4)->day,
				Carbon::today()->addDays(-3)->day,
				Carbon::today()->addDays(-2)->day,
				Carbon::today()->addDays(-1)->day,
				Carbon::today()->day,
			],
			'vips' => [
				(int)Statistic::fetch('total_vip_users_count_back4_day'),
				(int)Statistic::fetch('total_vip_users_count_back3_day'),
				(int)Statistic::fetch('total_vip_users_count_back2_day'),
				(int)Statistic::fetch('total_vip_users_count_back1_day'),
				(int)Statistic::fetch('total_vip_users_count_today'),
			],
			'normals' => [
				(int)Statistic::fetch('total_normal_users_count_back4_day'),
				(int)Statistic::fetch('total_normal_users_count_back3_day'),
				(int)Statistic::fetch('total_normal_users_count_back2_day'),
				(int)Statistic::fetch('total_normal_users_count_back1_day'),
				(int)Statistic::fetch('total_normal_users_count_today'),
			]
		];
	}
	
	public function usersConsist()
	{
		return [
			'labels' => [
				'普通会员',
				'VIP会员',
			],
			'counts' => [
				(int)User::query()->where("grade",'normal')->count(),
				(int)User::query()->where("vip_expired_at",">",Carbon::now())->where("grade",'vip')->count(),
			]
		];
	}
	
	public function stormRecordsIncrease()
	{
		return [
			'labels' => [
				'星级会员',
				'团长',
			],
			'counts' => [
				(int)User::query()->where("vip_expired_at",">",Carbon::now())->where('user_level',">",0)->count(),
				(int)User::query()->where("vip_expired_at",">",Carbon::now())->where('team_level',">",0)->count(),
			]
		];
	}
}
